package com.googlecode.afdbaccess.web.portal.exceptionmappers;

import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;

import org.jboss.resteasy.spi.BadRequestException;

import com.googlecode.afdbaccess.web.common.exception.GuiLayerWrappedException;

@Provider
public class BadRequestExceptionMapper implements ExceptionMapper<BadRequestException>
{
    @Override
    public Response toResponse(BadRequestException exception) {
        String reason = "Bad request";
        GuiLayerWrappedException guiLayerException = new GuiLayerWrappedException(reason, exception.getMessage(), exception);
        guiLayerException.setHttpReturnCode(400);
        throw new RuntimeException(reason, guiLayerException);
    }
}
